package com.ruoyi.system.task;


import com.ruoyi.system.service.impl.GatherDataUtil;
import org.springframework.beans.factory.annotation.Autowired;

public class TimeConsumingTask implements Runnable {
    @Autowired
    private GatherDataUtil gatherDataUtil;

    private final Long eventId;

    private final Long topicId;

    public TimeConsumingTask(Long eventId,Long topicId) {
        this.eventId=eventId;
        this.topicId=topicId;
    }

    @Override
    public void run() {
        System.out.println("耗时任务开始执行");
        // 模拟耗时操作，如网络请求、文件读写等
        if(eventId!=null){
            gatherDataUtil.startGatherData(eventId);
        }
        if(topicId!=null) {
            gatherDataUtil.startGatherDataByTopic(topicId);
        }


        System.out.println("耗时任务执行完毕");
    }
}
